package main.java.class_99_逸泽.第二次作业;

import org.junit.jupiter.api.Test;

import java.util.Scanner;

public class TestDemo02 {
    @Test
    public void test01() {
        for (int i = 101; i < 201; i++) {
            for (int j = 2; j < i + 1; j++) {
                if (i % j == 0 && j < i)
                    break;
                else if (j == i)
                    System.out.print(i + " ");
            }
        }
    }

    @Test
    public void test02() {
        for (int i = 100; i < 999; i++) {
            int a, b, c, n;
            a = i / 100;
            b = (i - 100 * a) / 10;
            c = i % 10;
            n = (int) (Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3));
            if (n == i)
                System.out.print(i + " ");
        }
    }

    @Test
    public void test03() {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个正整数：");
        int n = sc.nextInt();
        System.out.print(n + "= ");

        for (int i = 2 ;i< n+1;i++){
            while (n%i == 0 & n != i){
                n /= i;
                System.out.print(i + "*");
            }
            if (n == i) {
                    System.out.println(i);
                    break;
                }
            }
        }
    }
